// 1.获取GET请求内容
var http = require("http");
var url = require("url");
var util = require("util");

http
  .createServer(function (req, res) {
    res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
    res.end(util.inspect(url.parse(req.url, true)));
  })
  .listen(3000);

// 2.获取 URL 的参数
var http = require("http");
var url = require("url");
var util = require("util");

http
  .createServer(function (req, res) {
    res.writeHead(200, { "Content-Type": "text/plain; charset=utf8" });
    // 解析 url 参数
    var params = url.parse(req.url, true).query;
    res.write("网站名：" + params.name);
    res.write("\n");
    res.write("网站 URL：" + params.url);
    res.end();
  })
  .listen(3001);

console.log("http://127.0.0.1:3001/?name=11&url=111");
